home *** CD-ROM | disk | FTP | other *** search
- Path: hdxx05.telecom.ptt.nl!usenet
- From: A.B.deVries@PTT-Telecom.NL (Fred de Vries)
- Newsgroups: comp.lang.c
- Subject: Re: Newbie Q: Arrays > 64K take 2
- Date: 8 Feb 1996 11:39:38 GMT
- Organization: PTT Telecom B.V.
- Message-ID: <4fcndq$1pl@hdxx05.telecom.ptt.nl>
- References: <4f5k8p$dg4@earth.superlink.net>
- NNTP-Posting-Host: 138.204.177.15
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- In article <4f5k8p$dg4@earth.superlink.net>, rizzom@mars.superlink.net says...
- >
- >Hi,
- >
- > I'm using Turbo C++ (compliing in C) with DOS. I am having
- >trouble with an arrya larger than 64K. I keep getting the
- >error: Array too large. I have tried the medium, compact,
- >large, and huge memory models but they did not work. Here is
- >the definition of the struture and declaration of the array:
- >
- >typedef enum {IDLE = 0, BUSY = 1} proc_state;
- >
- >typedef struct
- > {
- > char inst[10];
- > }InstString;
- >
- >typedef struct
- > {
- > int datamem[102];
- > InstString instruct[102];
- > proc_state state;
- > int PC;
- > char IR[10];
- > int AC;
- > }VMProc;
- >
- >main()
- >{
- >VMProc proc[64];
- >..
- >}
-
- Try something like:
-
- main()
- {
- VMProc *proc[64];
- int ndx;
-
- ...
- for (ndx=0; ndx<64; ndx++)
- proc[ndx] = (VMProc *)malloc(sizeof VMProc);
- ...
- }
-
- Now each element is seperatly allocated, so no problems with
- segment sizes/boundaries.
-
- Just keep in mind that:
- a) proc[n] is a POINTER to a structure, NOT a structure
- by itself!!!
- b) Check the returnvalue of malloc() to be sure you really
- did get some memory!
-
-
- Hope this helps
-
- ----------------------------------------------------------------------------
- Fred de Vries | Telephone: +31 70 3432511
- PTT Telecom BV | Telefax : +31 70 3436393
- I&AT TU B&O | E-mail : A.B.deVries@PTT-Telecom.NL
- P.O. 423 | X.400 : C=NL A=400NET O=DLC
- NL-2260 AK Leidschendam | S=De Vries G=Fred
- The Netherlands |
- DISCLAIMER: This statement is not an official statement from, nor
- does it represent an official position of, PTT Telecom B.V.
- ----------------------------------------------------------------------------
-
-